<!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <title>后台管理</title>
    <link rel="stylesheet" type="text/css" href="{:asset('h-ui.admin/css/')}main.css"/>
    <link rel="stylesheet" href="{:asset('admin/vendors/bootstrap/css/bootstrap.css')}">
    <link rel="stylesheet" href="{:asset('admin/vendors/font-awesome/css/font-awesome.css')}">
    <link rel="stylesheet" href="{:asset('admin/vendors/nprogress/nprogress.css')}">
    <link href="{:asset('HHuploadify-master/dist/HHuploadify.css')}" rel="stylesheet" type="text/css" >
    <script src="{:asset('HHuploadify-master/dist/HHuploadify.js')}" type="text/javascript" ></script>
</head>
<body>
<div class="container clearfix">
    <div class="main-wrap">
        <div class="result-wrap">
            <div class="result-content">
                <form action="" method="post" id="myform" >
                    <input type="hidden" name="id" value="{$date.id}">
                    <table class="insert-tab" width="100%">
                        <div class="form-group">
                            <label for="exampleInputEmail1">分类名称</label>
                            <input type="text" name="title" class="form-control" value="{$date.title}" id="exampleInputEmail1" placeholder="分类名称">
                        </div>
                        <div class="form-group">
                            <img src="http://www.blog.com/{$date.mylogo}" width="80px" alt="">
                            <label class="col-sm-3 control-label">分类图片</label>
                            <div class="col-sm-6" id="goodslogo">
                            </div>
                            <input type="hidden" name="mylogo" id="goods_logo" value="{$date.mylogo}" />
                        </div>
                        <textarea name="content" id="inputPassword3" class="form-control" rows="3">{$date.content}</textarea>
                        <tr>
                            <th></th>
                            <td>
                                <input class="btn btn-primary btn6 mr10" value="修改" type="submit">
                            </td>
                        </tr>
                    </table>
                </form>
            </div>

        </div>

    </div>
    <!--/右侧主操作区-->
</div>
</body>
<script src="{:asset('admin/vendors/jquery/jquery.js')}"></script>
<script src="{:asset('layer/layer.js')}"></script>
<script>
    $(function(){
       $('#myform').submit(function(evt){
           evt.preventDefault();
           var shuju =$(this).serialize();
           $.ajax({
               url:"cateupd",
               data:shuju,
               type:'post',
               dataType:'json',
               success:function(msg){
                    if(msg==1){
                        layer.alert('修改成功',{icon:6},function(){
                            window.parent.location.reload();
                        })
                    }else if(msg==2){
                        layer.alert('请从新填写内容',{icon:5})
                    }else{
                        layer.alert(msg,{icon:5})
                    }
               }
           })
       })
        new HHuploadify({
            container:'#goodslogo',
            single:true,
            chooseText:'选取图片',
            auto:true,
            url:"{:url('admin/cate/update')}",
            field:'mylogo',
            //上传成功后的回调函数
            onUploadSuccess:function(file,data){
                var obj =JSON.parse(data);
                if(obj.status=='success'){
                    $('#goods_logo').val(obj.logo);

                }else{
                    layer.msg('上传图片失败',{icon:5,time:1000});
                }
            },
            onRemoved:function(){
                $('#goods_logo').val('');
            }
        });
    })
</script>
</html>